layui.config({
  base: "js/"
}).use(['form', 'layer', 'jquery', 'layedit', 'laydate'], function () {
  var form = layui.form(),
    layer = parent.layer === undefined ? layui.layer : parent.layer,
    laypage = layui.laypage,
    layedit = layui.layedit,
    laydate = layui.laydate,
    $ = layui.jquery;


  form.on("submit(submit)", function (data) {
    console.log(data.field);
    //弹出loading
    var index = layer.msg('数据提交中，请稍候', {icon: 16, time: 3000, shade: 0.8});
    $.ajax({
      url: "/api/user",
      type: "POST",
      data: data.field,
      dataType: "json",
      success: function (data) {
        console.log(data);
        layer.close(index);
        top.layer.msg("修改成功！");
        layer.closeAll("iframe");
      },
      error: function (data) {
        layer.close(index);
        top.layer.msg("修改失败！");
      }
    });
    return false;
  })

});
